package com.jack006.api.config;


import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.OkHttp3ClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;


/**
 * @Classname CloudConfig
 * @Description 前端跨域问题处理
 * @Date 2021-06-13 15:14
 * @Created by jack
 */
@Configuration
public class CloudConfig {


    public CloudConfig() {
    }

    /**
     * 会基于 OKHttp3 的配置来配置 RestTemplate
     *
     * @return
     */
    @Bean
    @LoadBalanced // 默认的负载均衡算法； 轮询
    public RestTemplate restTemplate() {
        return new RestTemplate(new OkHttp3ClientHttpRequestFactory());
    }

}
